package com.itheima.health.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.health.dao.MemberDao;
import com.itheima.health.pojo.Member;
import com.itheima.health.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.UUID;

/**
 * @autahor: csl
 * @date: 2019/7/26
 * @description: 会员登录实现类
 * @version:1.0
 */
@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    private MemberDao dao;
    @Override
    public boolean login(String telephone) {
        Member member = dao.findMemberByTelephone(telephone);
        if (member==null ){
            member = new Member();
            member.setName(UUID.randomUUID()+"");
            member.setRegTime(new Date());
            member.setPhoneNumber(telephone);
            dao.addMember(member);
        }
        return true;
    }
}
